/*
 * jxNFe Project (2014)
 * 
 * by Denilson Edinaldo Pinto
 * 
 * LGPL
 * Copyright (C) 2014
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
package org.jxNFe.util;

import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import java.io.Writer;
import java.net.URL;

import javax.xml.bind.JAXBException;

import org.jxNFe.model.v310.TNFe;
import org.jxNFe.model.v310.TNfeProc;
import org.jxUtils.xml.XMLUtil;

/**
 * @author Denilson Edinaldo Pinto
 * @porject jxNFe
 * @package org.jxNFe.util
 * @date 08/11/2014 - 10:02:27
 */
public class JXNFeUtil {
	
	/**
	 * @param xmlFile
	 * @return {@link TNFe}
	 * @throws JAXBException
	 */
	public static final TNFe readNfe(final File xmlFile) throws JAXBException {
	
		return XMLUtil.read(xmlFile, TNFe.class);
	}
	
	/**
	 * @param xmlStream
	 * @return {@link TNFe}
	 * @throws JAXBException
	 */
	public static final TNFe readNfe(final InputStream xmlStream) throws JAXBException {
	
		return XMLUtil.read(xmlStream, TNFe.class);
	}
	
	/**
	 * @param xmlReader
	 * @return {@link TNFe}
	 * @throws JAXBException
	 */
	public static final TNFe readNfe(final Reader xmlReader) throws JAXBException {
	
		return XMLUtil.read(xmlReader, TNFe.class);
	}
	
	/**
	 * @param xmlUrl
	 * @return {@link TNFe}
	 * @throws JAXBException
	 */
	public static final TNFe readNfe(final URL xmlUrl) throws JAXBException {
	
		return XMLUtil.read(xmlUrl, TNFe.class);
	}
	
	/**
	 * @param xmlFile
	 * @return {@link TNfeProc}
	 * @throws JAXBException
	 */
	public static final TNfeProc readNfeProc(final File xmlFile) throws JAXBException {
	
		return XMLUtil.read(xmlFile, TNfeProc.class);
	}
	
	/**
	 * @param xmlStream
	 * @return {@link TNfeProc}
	 * @throws JAXBException
	 */
	public static final TNfeProc readNfeProc(final InputStream xmlStream) throws JAXBException {
	
		return XMLUtil.read(xmlStream, TNfeProc.class);
	}
	
	/**
	 * @param xmlReader
	 * @return {@link TNfeProc}
	 * @throws JAXBException
	 */
	public static final TNfeProc readNfeProc(final Reader xmlReader) throws JAXBException {
	
		return XMLUtil.read(xmlReader, TNfeProc.class);
	}
	
	/**
	 * @param xmlUrl
	 * @return {@link TNfeProc}
	 * @throws JAXBException
	 */
	public static final TNfeProc readNfeProc(final URL xmlUrl) throws JAXBException {
	
		return XMLUtil.read(xmlUrl, TNfeProc.class);
	}
	
	/**
	 * @param nfe
	 * @param xmlFile
	 * @throws JAXBException
	 */
	public static final void writeNfe(final TNFe nfe, final File xmlFile) throws JAXBException {
	
		XMLUtil.write(nfe, xmlFile, true);
	}
	
	/**
	 * @param nfe
	 * @param xmlFile
	 * @param formated
	 * @throws JAXBException
	 */
	public static final void writeNfe(final TNFe nfe, final File xmlFile, final boolean formated) throws JAXBException {
	
		XMLUtil.write(nfe, xmlFile, formated);
	}
	
	/**
	 * @param nfe
	 * @param xmlStream
	 * @throws JAXBException
	 */
	public static final void writeNfe(final TNFe nfe, final OutputStream xmlStream) throws JAXBException {
	
		XMLUtil.write(nfe, xmlStream, true);
	}
	
	/**
	 * @param nfe
	 * @param xmlStream
	 * @param formated
	 * @throws JAXBException
	 */
	public static final void writeNfe(final TNFe nfe, final OutputStream xmlStream, final boolean formated) throws JAXBException {
	
		XMLUtil.write(nfe, xmlStream, formated);
	}
	
	/**
	 * @param nfe
	 * @param xmlWriter
	 * @throws JAXBException
	 */
	public static final void writeNfe(final TNFe nfe, final Writer xmlWriter) throws JAXBException {
	
		XMLUtil.write(nfe, xmlWriter, true);
	}
	
	/**
	 * @param nfe
	 * @param xmlWriter
	 * @param formated
	 * @throws JAXBException
	 */
	public static final void writeNfe(final TNFe nfe, final Writer xmlWriter, final boolean formated) throws JAXBException {
	
		XMLUtil.write(nfe, xmlWriter, formated);
	}
	
	/**
	 * @param nfeProc
	 * @param xmlFile
	 * @throws JAXBException
	 */
	public static final void writeNfeProc(final TNfeProc nfeProc, final File xmlFile) throws JAXBException {
	
		XMLUtil.write(nfeProc, xmlFile, true);
	}
	
	/**
	 * @param nfeProc
	 * @param xmlFile
	 * @param formated
	 * @throws JAXBException
	 */
	public static final void writeNfeProc(final TNfeProc nfeProc, final File xmlFile, final boolean formated) throws JAXBException {
	
		XMLUtil.write(nfeProc, xmlFile, formated);
	}
	
	/**
	 * @param nfeProc
	 * @param xmlStream
	 * @throws JAXBException
	 */
	public static final void writeNfeProc(final TNfeProc nfeProc, final OutputStream xmlStream) throws JAXBException {
	
		XMLUtil.write(nfeProc, xmlStream, true);
	}
	
	/**
	 * @param nfeProc
	 * @param xmlStream
	 * @param formated
	 * @throws JAXBException
	 */
	public static final void writeNfeProc(final TNfeProc nfeProc, final OutputStream xmlStream, final boolean formated) throws JAXBException {
	
		XMLUtil.write(nfeProc, xmlStream, formated);
	}
	
	/**
	 * @param nfeProc
	 * @param xmlWriter
	 * @throws JAXBException
	 */
	public static final void writeNfeProc(final TNfeProc nfeProc, final Writer xmlWriter) throws JAXBException {
	
		XMLUtil.write(nfeProc, xmlWriter, true);
	}
	
	/**
	 * @param nfeProc
	 * @param xmlWriter
	 * @param formated
	 * @throws JAXBException
	 */
	public static final void writeNfeProc(final TNfeProc nfeProc, final Writer xmlWriter, final boolean formated) throws JAXBException {
	
		XMLUtil.write(nfeProc, xmlWriter, formated);
	}
}
